﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace Testing_components
{
    public class PresentableDataPoint : INotifyPropertyChanged
    {

        private double _value;
        private DateTime _timestamp;

        public event PropertyChangedEventHandler PropertyChanged;
        private void OnPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        public PresentableDataPoint()
        {
            this._value = 0;
            this._timestamp = DateTime.Now;
        }

        public PresentableDataPoint(SensorDataDB sen)
        {
            this._value = sen.Value;
            this._timestamp = sen.TimeStamp;
        }


        public double Value
        {
            get { return _value; }
            set
            {
                if (_value != value) _value = value;
                OnPropertyChanged("Value");
            }
        }

        public DateTime TimeStamp
        {
            get { return _timestamp; }
            set
            {
                if (_timestamp != value) _timestamp = value;
                OnPropertyChanged("TimeStamp");
            }
        }
    }
}
